package com.sangeng.controller;

import com.sangeng.constant.enums.CommentConstants;
import com.sangeng.domain.core.ResponseResult;
import com.sangeng.domain.dto.CommentListDto;
import com.sangeng.domain.entity.Comment;
import com.sangeng.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 获取评论列表
     * @return
     */
    @GetMapping("/commentList")
    public ResponseResult commentList(CommentListDto commentListDto){
        return commentService.commentList(commentListDto);
    }

    /**
     * 添加评论
     * @param comment
     * @return
     */
    @PostMapping
    public ResponseResult addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }

    /**
     * 友链评论列表
     * @param commentListDto
     * @return
     */
    @GetMapping("/linkCommentList")
    public ResponseResult linkCommentList(CommentListDto commentListDto){
        commentListDto.setArticleId(CommentConstants.LINK_ID);
        return commentService.commentList(commentListDto);
    }

}
